﻿#region imports

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CondeNet.AssetManager.Data;
using CondeNet.AssetManager.Business;
using CondeNet.AssetManager.Business.Interface;

#endregion

namespace CondeNet.AssetManager.DataProvider.Sql.Mappers
{
    public static class RepositoryMapper
    {
        internal static IRepository ToBusinessObject ( T_Repository entity )
        {
            //if ( entity == null ) return new Repository ( );

            return new Repository (
                entity.Repository_IDPK ,
                entity.URLPrefix_NVC ,
                entity.Name_NVC ,
                entity.Description_NVC ,
                entity.Enabled_BIT );
        }

        internal static T_Repository ToEntity ( IRepository v )
        {
            T_Repository entity = new T_Repository ( );

            entity.Repository_IDPK = v.ID;
            entity.URLPrefix_NVC = v.URLPrefix;
            entity.Name_NVC = v.Name;
            entity.Description_NVC = v.Description;
            entity.Enabled_BIT = v.Enabled;

            return entity;
        }

        internal static IList<IRepository> ToBusinessObjects ( IList<T_Repository> dalList )
        {
            return dalList.Select ( tmp => ToBusinessObject ( tmp ) ).ToList ( );
        }

        internal static IList<T_Repository> ToEntities ( IList<IRepository> entityList )
        {
            return entityList.Select ( tmp => ToEntity ( tmp ) ).ToList ( );
        }
    }
}
